// MESSAGE ASCTEC_MOTOR_RPM PACKING

#define MAVLINK_MSG_ID_ASCTEC_MOTOR_RPM 3

typedef struct __mavlink_asctec_motor_rpm_t
{
 uint32_t msec; ///< Timestamp
 uint8_t motor[4]; ///< motor rpm 0...200
} mavlink_asctec_motor_rpm_t;

#define MAVLINK_MSG_ID_ASCTEC_MOTOR_RPM_LEN 8
#define MAVLINK_MSG_ID_3_LEN 8

#define MAVLINK_MSG_ASCTEC_MOTOR_RPM_FIELD_MOTOR_LEN 4

#define MAVLINK_MESSAGE_INFO_ASCTEC_MOTOR_RPM { \
	"ASCTEC_MOTOR_RPM", \
	2, \
	{  { "msec", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_asctec_motor_rpm_t, msec) }, \
         { "motor", NULL, MAVLINK_TYPE_UINT8_T, 4, 4, offsetof(mavlink_asctec_motor_rpm_t, motor) }, \
         } \
}


/**
 * @brief Pack a asctec_motor_rpm message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param msec Timestamp
 * @param motor motor rpm 0...200
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_asctec_motor_rpm_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       uint32_t msec, const uint8_t *motor)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[8];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_uint8_t_array(buf, 4, motor, 4);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
#else
	mavlink_asctec_motor_rpm_t packet;
	packet.msec = msec;
	mav_array_memcpy(packet.motor, motor, sizeof(uint8_t)*4);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
#endif

	msg->msgid = MAVLINK_MSG_ID_ASCTEC_MOTOR_RPM;
	return mavlink_finalize_message(msg, system_id, component_id, 8, 183);
}

/**
 * @brief Pack a asctec_motor_rpm message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param msec Timestamp
 * @param motor motor rpm 0...200
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_asctec_motor_rpm_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           uint32_t msec,const uint8_t *motor)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[8];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_uint8_t_array(buf, 4, motor, 4);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
#else
	mavlink_asctec_motor_rpm_t packet;
	packet.msec = msec;
	mav_array_memcpy(packet.motor, motor, sizeof(uint8_t)*4);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
#endif

	msg->msgid = MAVLINK_MSG_ID_ASCTEC_MOTOR_RPM;
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 8, 183);
}

/**
 * @brief Encode a asctec_motor_rpm struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param asctec_motor_rpm C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_asctec_motor_rpm_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_asctec_motor_rpm_t* asctec_motor_rpm)
{
	return mavlink_msg_asctec_motor_rpm_pack(system_id, component_id, msg, asctec_motor_rpm->msec, asctec_motor_rpm->motor);
}

/**
 * @brief Send a asctec_motor_rpm message
 * @param chan MAVLink channel to send the message
 *
 * @param msec Timestamp
 * @param motor motor rpm 0...200
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_asctec_motor_rpm_send(mavlink_channel_t chan, uint32_t msec, const uint8_t *motor)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[8];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_uint8_t_array(buf, 4, motor, 4);
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ASCTEC_MOTOR_RPM, buf, 8, 183);
#else
	mavlink_asctec_motor_rpm_t packet;
	packet.msec = msec;
	mav_array_memcpy(packet.motor, motor, sizeof(uint8_t)*4);
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ASCTEC_MOTOR_RPM, (const char *)&packet, 8, 183);
#endif
}

#endif

// MESSAGE ASCTEC_MOTOR_RPM UNPACKING


/**
 * @brief Get field msec from asctec_motor_rpm message
 *
 * @return Timestamp
 */
static inline uint32_t mavlink_msg_asctec_motor_rpm_get_msec(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint32_t(msg,  0);
}

/**
 * @brief Get field motor from asctec_motor_rpm message
 *
 * @return motor rpm 0...200
 */
static inline uint16_t mavlink_msg_asctec_motor_rpm_get_motor(const mavlink_message_t* msg, uint8_t *motor)
{
	return _MAV_RETURN_uint8_t_array(msg, motor, 4,  4);
}

/**
 * @brief Decode a asctec_motor_rpm message into a struct
 *
 * @param msg The message to decode
 * @param asctec_motor_rpm C-struct to decode the message contents into
 */
static inline void mavlink_msg_asctec_motor_rpm_decode(const mavlink_message_t* msg, mavlink_asctec_motor_rpm_t* asctec_motor_rpm)
{
#if MAVLINK_NEED_BYTE_SWAP
	asctec_motor_rpm->msec = mavlink_msg_asctec_motor_rpm_get_msec(msg);
	mavlink_msg_asctec_motor_rpm_get_motor(msg, asctec_motor_rpm->motor);
#else
	memcpy(asctec_motor_rpm, _MAV_PAYLOAD(msg), 8);
#endif
}
